<!DOCTYPE html>
<html><head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    
    <link rel="canonical" href="/unity-arpg/init/">

    <title>
        
        Init | h-book
        
    </title>

    
    <link href="/css/fontawesome.min.css" rel="stylesheet">

    
    <link rel="stylesheet" href="/css/ace.min.css">

    

    

</head>
<body><nav class="navbar navbar-expand-lg navbar-dark bg-primary shadow sticky-top" id="navbarMain">
    <div class="container">
        <div>
            <a class="navbar-brand" href="/">
                
                h-book
            </a>
        </div>
    </div>
</nav>
<div class="container-fluid">
            <div class="row">

                <div class="docs-sidenav order-0 col-12 col-md-3 col-lg-2 col-xl-2 position-sticky border-right"><nav class="navbar navbar-expand-md navbar-light pl-0">
    <button class="navbar-toggler navbar-toggler-right collapsed" type="button" data-toggle="collapse" data-target="#sidenav-left-collapse" aria-controls="sidenav-left-collapse" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

     <div class="collapse navbar-collapse align-items-start flex-column" id="sidenav-left-collapse">
            <form class="form-inline my-2 my-lg-0 searchbox">
                <input class="form-control mr-sm-2 w-100" data-search-input id="search-by" type="text" placeholder="Search">
            </form>

        

         <ul class="navbar-nav flex-column pt-3">
    <li data-nav-id="/hugo/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/hugo/"><h6>Hugo</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/hugo/init/" class="nav-item my-1">
                
                
                  <a href="/hugo/init/" class="nav-link p-0">
                    init
                  </a>
                
        </li>
        <li data-nav-id="/hugo/add-page/" class="nav-item my-1">
                
                
                  <a href="/hugo/add-page/" class="nav-link p-0">
                    add-page
                  </a>
                
        </li>
        <li data-nav-id="/hugo/edit-skill/" class="nav-item my-1">
                
                
                  <a href="/hugo/edit-skill/" class="nav-link p-0">
                    edit-skill
                  </a>
                
        </li>
        <li data-nav-id="/hugo/publish/" class="nav-item my-1">
                
                
                  <a href="/hugo/publish/" class="nav-link p-0">
                    publish
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/android/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/android/"><h6>Android</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/android/install/" class="nav-item my-1">
                
                
                  <a href="/android/install/" class="nav-link p-0">
                    install
                  </a>
                
        </li>
        <li data-nav-id="/android/create-project/" class="nav-item my-1">
                
                
                  <a href="/android/create-project/" class="nav-link p-0">
                    create project
                  </a>
                
        </li>
        <li data-nav-id="/android/import-material/" class="nav-item my-1">
                
                
                  <a href="/android/import-material/" class="nav-link p-0">
                    import material
                  </a>
                
        </li>
        <li data-nav-id="/android/start-page/" class="nav-item my-1">
                
                
                  <a href="/android/start-page/" class="nav-link p-0">
                    startpage
                  </a>
                
        </li>
        <li data-nav-id="/android/i18n/" class="nav-item my-1">
                
                
                  <a href="/android/i18n/" class="nav-link p-0">
                    i18n
                  </a>
                
        </li>
        <li data-nav-id="/android/nav-flat-page/" class="nav-item my-1">
                
                
                  <a href="/android/nav-flat-page/" class="nav-link p-0">
                    nav flat page
                  </a>
                
        </li>
        <li data-nav-id="/android/activity/" class="nav-item my-1">
                
                
                  <a href="/android/activity/" class="nav-link p-0">
                    Activity
                  </a>
                
        </li>
        <li data-nav-id="/android/db/" class="nav-item my-1">
                
                
                  <a href="/android/db/" class="nav-link p-0">
                    DB
                  </a>
                
        </li>
        <li data-nav-id="/android/dialog/" class="nav-item my-1">
                
                
                  <a href="/android/dialog/" class="nav-link p-0">
                    Dialog
                  </a>
                
        </li>
        <li data-nav-id="/android/fragment/" class="nav-item my-1">
                
                
                  <a href="/android/fragment/" class="nav-link p-0">
                    Fragment
                  </a>
                
        </li>
        <li data-nav-id="/android/jetpack/" class="nav-item my-1">
                
                
                  <a href="/android/jetpack/" class="nav-link p-0">
                    Jetpack
                  </a>
                
        </li>
        <li data-nav-id="/android/material/" class="nav-item my-1">
                
                
                  <a href="/android/material/" class="nav-link p-0">
                    Material
                  </a>
                
        </li>
        <li data-nav-id="/android/storage/" class="nav-item my-1">
                
                
                  <a href="/android/storage/" class="nav-link p-0">
                    Storage
                  </a>
                
        </li>
        <li data-nav-id="/android/%E5%9B%BE%E6%A0%87/" class="nav-item my-1">
                
                
                  <a href="/android/%E5%9B%BE%E6%A0%87/" class="nav-link p-0">
                    图标
                  </a>
                
        </li>
        <li data-nav-id="/android/store/" class="nav-item my-1">
                
                
                  <a href="/android/store/" class="nav-link p-0">
                    Store
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/blender/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/blender/"><h6>Blender</h6></a>
        
    </li>
    <li data-nav-id="/bootstrap/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/bootstrap/"><h6>BootStrap</h6></a>
        
    </li>
    <li data-nav-id="/centos7/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/centos7/"><h6>Centos7</h6></a>
        
    </li>
    <li data-nav-id="/dlna/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/dlna/"><h6>DLNA</h6></a>
        
    </li>
    <li data-nav-id="/docker/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/docker/"><h6>Docker</h6></a>
        
    </li>
    <li data-nav-id="/dubbo/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/dubbo/"><h6>Dubbo</h6></a>
        
    </li>
    <li data-nav-id="/ffmpeg/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/ffmpeg/"><h6>FFmpeg</h6></a>
        
    </li>
    <li data-nav-id="/git/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/git/"><h6>Git</h6></a>
        
    </li>
    <li data-nav-id="/gitbook/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/gitbook/"><h6>Gitbook</h6></a>
        
    </li>
    <li data-nav-id="/gitlab/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/gitlab/"><h6>Gitlab</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/gitlab/runner/" class="nav-item my-1">
                
                
                  <a href="/gitlab/runner/" class="nav-link p-0">
                    Runner
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/gradle/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/gradle/"><h6>Gradle</h6></a>
        
    </li>
    <li data-nav-id="/java/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/java/"><h6>Java</h6></a>
        
    </li>
    <li data-nav-id="/jenkins/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/jenkins/"><h6>Jenkins</h6></a>
        
    </li>
    <li data-nav-id="/kubernetes/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/kubernetes/"><h6>Kubernetes</h6></a>
        
    </li>
    <li data-nav-id="/mybatis/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/mybatis/"><h6>Mybatis</h6></a>
        
    </li>
    <li data-nav-id="/mybatis-plus/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/mybatis-plus/"><h6>Mybatis Plus</h6></a>
        
    </li>
    <li data-nav-id="/mysql/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/mysql/"><h6>MySQL</h6></a>
        
    </li>
    <li data-nav-id="/nodejs/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/nodejs/"><h6>Node.js</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/nodejs/npm/" class="nav-item my-1">
                
                
                  <a href="/nodejs/npm/" class="nav-link p-0">
                    NPM
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/postgresql/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/postgresql/"><h6>PostgreSQL</h6></a>
        
    </li>
    <li data-nav-id="/redis/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/redis/"><h6>Redis</h6></a>
        
    </li>
    <li data-nav-id="/samba/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/samba/"><h6>Samba</h6></a>
        
    </li>
    <li data-nav-id="/sql/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/sql/"><h6>SQL</h6></a>
        
    </li>
    <li data-nav-id="/ue5/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/ue5/"><h6>UE5</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/ue5/install/" class="nav-item my-1">
                
                
                  <a href="/ue5/install/" class="nav-link p-0">
                    install
                  </a>
                
        </li>
        <li data-nav-id="/ue5/uninstall/" class="nav-item my-1">
                
                
                  <a href="/ue5/uninstall/" class="nav-link p-0">
                    uninstall
                  </a>
                
        </li>
        <li data-nav-id="/ue5/qa/" class="nav-item my-1">
                
                
                  <a href="/ue5/qa/" class="nav-link p-0">
                    Q&amp;A
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity/"><h6>Unity</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity/install/" class="nav-item my-1">
                
                
                  <a href="/unity/install/" class="nav-link p-0">
                    install
                  </a>
                
        </li>
        <li data-nav-id="/unity/scene/" class="nav-item my-1">
                
                
                  <a href="/unity/scene/" class="nav-link p-0">
                    scene
                  </a>
                
        </li>
        <li data-nav-id="/unity/inspector/" class="nav-item my-1">
                
                
                  <a href="/unity/inspector/" class="nav-link p-0">
                    inspector
                  </a>
                
        </li>
        <li data-nav-id="/unity/assets/" class="nav-item my-1">
                
                
                  <a href="/unity/assets/" class="nav-link p-0">
                    assets
                  </a>
                
        </li>
        <li data-nav-id="/unity/audio-source/" class="nav-item my-1">
                
                
                  <a href="/unity/audio-source/" class="nav-link p-0">
                    audio source
                  </a>
                
        </li>
        <li data-nav-id="/unity/camera/" class="nav-item my-1">
                
                
                  <a href="/unity/camera/" class="nav-link p-0">
                    camera
                  </a>
                
        </li>
        <li data-nav-id="/unity/script/" class="nav-item my-1">
                
                
                  <a href="/unity/script/" class="nav-link p-0">
                    script
                  </a>
                
        </li>
        <li data-nav-id="/unity/prefabs/" class="nav-item my-1">
                
                
                  <a href="/unity/prefabs/" class="nav-link p-0">
                    prefabs
                  </a>
                
        </li>
        <li data-nav-id="/unity/physics/" class="nav-item my-1">
                
                
                  <a href="/unity/physics/" class="nav-link p-0">
                    physics
                  </a>
                
        </li>
        <li data-nav-id="/unity/skybox/" class="nav-item my-1">
                
                
                  <a href="/unity/skybox/" class="nav-link p-0">
                    skybox
                  </a>
                
        </li>
        <li data-nav-id="/unity/particle-system/" class="nav-item my-1">
                
                
                  <a href="/unity/particle-system/" class="nav-link p-0">
                    particle system
                  </a>
                
        </li>
        <li data-nav-id="/unity/shortcut-keys/" class="nav-item my-1">
                
                
                  <a href="/unity/shortcut-keys/" class="nav-link p-0">
                    shortcut keys
                  </a>
                
        </li>
        <li data-nav-id="/unity/qa/" class="nav-item my-1">
                
                
                  <a href="/unity/qa/" class="nav-link p-0">
                    Q&amp;A
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-2d-beginner/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-2d-beginner/"><h6>Unity 2D Beginner</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-2d-beginner/init-and-move/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/init-and-move/" class="nav-link p-0">
                    Init &amp; Move
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/map/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/map/" class="nav-link p-0">
                    Map
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/data/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/data/" class="nav-link p-0">
                    Data
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/animate/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/animate/" class="nav-link p-0">
                    Data
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/bullet/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/bullet/" class="nav-link p-0">
                    Bullet
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/cinemachine/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/cinemachine/" class="nav-link p-0">
                    Cinemachine
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/particle/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/particle/" class="nav-link p-0">
                    Particle
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/ui/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/ui/" class="nav-link p-0">
                    UI
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/npc/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/npc/" class="nav-link p-0">
                    NPC
                  </a>
                
        </li>
        <li data-nav-id="/unity-2d-beginner/sound/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-beginner/sound/" class="nav-link p-0">
                    Sound
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-2d-game-kit/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-2d-game-kit/"><h6>Unity 2D Game Kit</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-2d-game-kit/record/" class="nav-item my-1">
                
                
                  <a href="/unity-2d-game-kit/record/" class="nav-link p-0">
                    record
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-3d-beginner/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-3d-beginner/"><h6>Unity 3D Beginner</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-3d-beginner/init/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/init/" class="nav-link p-0">
                    Init
                  </a>
                
        </li>
        <li data-nav-id="/unity-3d-beginner/level/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/level/" class="nav-link p-0">
                    Level
                  </a>
                
        </li>
        <li data-nav-id="/unity-3d-beginner/nav/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/nav/" class="nav-link p-0">
                    Nav
                  </a>
                
        </li>
        <li data-nav-id="/unity-3d-beginner/render-pipeline/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/render-pipeline/" class="nav-link p-0">
                    Render Pipeline
                  </a>
                
        </li>
        <li data-nav-id="/unity-3d-beginner/postprocessing/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/postprocessing/" class="nav-link p-0">
                    PostProcessing
                  </a>
                
        </li>
        <li data-nav-id="/unity-3d-beginner/ui/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/ui/" class="nav-link p-0">
                    UI
                  </a>
                
        </li>
        <li data-nav-id="/unity-3d-beginner/enemy/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/enemy/" class="nav-link p-0">
                    Enemy
                  </a>
                
        </li>
        <li data-nav-id="/unity-3d-beginner/sound/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/sound/" class="nav-link p-0">
                    Sound
                  </a>
                
        </li>
        <li data-nav-id="/unity-3d-beginner/%E5%BB%BA%E6%A8%A1%E5%B7%A5%E5%85%B7/" class="nav-item my-1">
                
                
                  <a href="/unity-3d-beginner/%E5%BB%BA%E6%A8%A1%E5%B7%A5%E5%85%B7/" class="nav-link p-0">
                    建模工具
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-arpg/" class="nav-item my-1 parent haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-arpg/"><h6>Unity ARPG</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-arpg/init/" class="nav-item my-1 active">
                
                
                  <a href="/unity-arpg/init/" class="nav-link p-0">
                    Init
                  </a>
                
        </li>
        <li data-nav-id="/unity-arpg/role-state-machine/" class="nav-item my-1">
                
                
                  <a href="/unity-arpg/role-state-machine/" class="nav-link p-0">
                    Role State Machine
                  </a>
                
        </li>
        <li data-nav-id="/unity-arpg/api-piece/" class="nav-item my-1">
                
                
                  <a href="/unity-arpg/api-piece/" class="nav-link p-0">
                    API Piece
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-creativecore-animation/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-creativecore-animation/"><h6>Unity Creativecore Animation</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-creativecore-animation/door/" class="nav-item my-1">
                
                
                  <a href="/unity-creativecore-animation/door/" class="nav-link p-0">
                    Door
                  </a>
                
        </li>
        <li data-nav-id="/unity-creativecore-animation/init/" class="nav-item my-1">
                
                
                  <a href="/unity-creativecore-animation/init/" class="nav-link p-0">
                    Init
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-creativecore-lighting/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-creativecore-lighting/"><h6>Unity Creativecore Lighting</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-creativecore-lighting/init/" class="nav-item my-1">
                
                
                  <a href="/unity-creativecore-lighting/init/" class="nav-link p-0">
                    Init
                  </a>
                
        </li>
        <li data-nav-id="/unity-creativecore-lighting/outdoor/" class="nav-item my-1">
                
                
                  <a href="/unity-creativecore-lighting/outdoor/" class="nav-link p-0">
                    Outdoor
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-creativecore-shader/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-creativecore-shader/"><h6>Unity Creativecore Shader</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-creativecore-shader/init/" class="nav-item my-1">
                
                
                  <a href="/unity-creativecore-shader/init/" class="nav-link p-0">
                    Init
                  </a>
                
        </li>
        <li data-nav-id="/unity-creativecore-shader/glass/" class="nav-item my-1">
                
                
                  <a href="/unity-creativecore-shader/glass/" class="nav-link p-0">
                    Glass
                  </a>
                
        </li>
        <li data-nav-id="/unity-creativecore-shader/shader-graph/" class="nav-item my-1">
                
                
                  <a href="/unity-creativecore-shader/shader-graph/" class="nav-link p-0">
                    Shader-Graph
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-creator-kit-beginner-code/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-creator-kit-beginner-code/"><h6>Unity Creator Kit Beginner Code</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-creator-kit-beginner-code/record/" class="nav-item my-1">
                
                
                  <a href="/unity-creator-kit-beginner-code/record/" class="nav-link p-0">
                    record
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-creator-kit-fps/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-creator-kit-fps/"><h6>Unity Creator Kit FPS</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-creator-kit-fps/record/" class="nav-item my-1">
                
                
                  <a href="/unity-creator-kit-fps/record/" class="nav-link p-0">
                    record
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-mythirdperson/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-mythirdperson/"><h6>Unity My Third Person</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-mythirdperson/init/" class="nav-item my-1">
                
                
                  <a href="/unity-mythirdperson/init/" class="nav-link p-0">
                    Init
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-playground/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-playground/"><h6>Unity Playground</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-playground/record/" class="nav-item my-1">
                
                
                  <a href="/unity-playground/record/" class="nav-link p-0">
                    record
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-ui/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-ui/"><h6>Unity UI</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-ui/init/" class="nav-item my-1">
                
                
                  <a href="/unity-ui/init/" class="nav-link p-0">
                    record
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/unity-vfx/" class="nav-item my-1 haschildren
        ">
        
        
          <a class="nav-link p-0" href="/unity-vfx/"><h6>Unity VFX</h6></a>
        
        <ul class="list-unstyled ml-2">
        <li data-nav-id="/unity-vfx/init/" class="nav-item my-1">
                
                
                  <a href="/unity-vfx/init/" class="nav-link p-0">
                    record
                  </a>
                
        </li>
        <li data-nav-id="/unity-vfx/bullet/" class="nav-item my-1">
                
                
                  <a href="/unity-vfx/bullet/" class="nav-link p-0">
                    bullet
                  </a>
                
        </li>
        <li data-nav-id="/unity-vfx/rain/" class="nav-item my-1">
                
                
                  <a href="/unity-vfx/rain/" class="nav-link p-0">
                    rain
                  </a>
                
        </li>
        <li data-nav-id="/unity-vfx/rock-rain/" class="nav-item my-1">
                
                
                  <a href="/unity-vfx/rock-rain/" class="nav-link p-0">
                    Rock Rain
                  </a>
                
        </li>
        </ul>
    </li>
    <li data-nav-id="/vue/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/vue/"><h6>Vue</h6></a>
        
    </li>
    <li data-nav-id="/web/" class="nav-item my-1
        ">
        
        
          <a class="nav-link p-0" href="/web/"><h6>Web</h6></a>
        
    </li>
        </ul>
    </div>
</nav>


</div>
                <div class="docs-toc large order-lg-2 order-md-0 order-xs-1 col-12 col-lg-2 col-xl-2 position-sticky border-left"><div class="docs-toc">
	<nav id="TableOfContents">
  <ul>
    <li><a href="#创建工程">创建工程</a></li>
    <li><a href="#认识扩展工具">认识扩展工具</a></li>
    <li><a href="#读-excel-表生成-cs-文件">读 excel 表，生成 cs 文件</a></li>
  </ul>
</nav>
</div>
</div>
                <div class="main col-12 order-1 col-md-9 col-lg-10 col-xl-8 py-3">
                

<div class="d-flex flex-column">
    <h1 class="js-title">Init</h1>
    <div class="d-flex align-items-center">
        
    </div>
</div>

<hr>


<p>2024.10.10</p>
<h2 id="创建工程">创建工程</h2>
<ol>
<li>下载 High Definition 3D 工程模板，并创建名为 <code>ARPG1</code> 的工程</li>
<li>进入编辑器后会弹出 HDRP Wizard 对话框，关闭即可</li>
<li>将课程 unitypackage 包拖拽到 Assets 中，经一段时间等待后，在 Import Unity Package 对话框中确认全部勾选，并点击 Import 。再等待一段时间后，对 The open scene(s) have been modified externally 对话框点击 Reload</li>
</ol>
<p>课程用的是 2023.2.12 下载的 HDRP 模板，然后在 2023.1.20 中创建。本环境是 2022.3.40f1 ，在导入时 Assets\Settings 目录下个别文件会提示为替换，经比较后，文件内容并无区别</p>
<ol start="4">
<li>Reload 后对如下对话框进行勾选和点击 Agree</li>
</ol>
<p><img src="OdinEULA.png" alt="alt OdinEULA"></p>
<p>这个是 Odin Inspector &amp; Serializer 插件。其官网 <a href="https://odininspector.com/">https://odininspector.com/</a> 打不开，于 <a href="https://assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serializer-89041">https://assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serializer-89041</a> 可以查看到最新版本为 3.3.1.9 。功能是 <code>通过更高级的属性和方法，扩展 Unity 编辑器</code></p>
<p>位于 Assets/Plugins/Sirenix 目录下</p>
<ol start="5">
<li>下方会有很多警告和一些错误，错误包括</li>
</ol>
<p>和 OdinEULA 相关的，疑似与 <code>Y:/</code> 路径相关，暂时忽略</p>
<div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-txt" data-lang="txt"><span style="display:flex;"><span>Unable to import newly created asset : Assets/Plugins/Sirenix/Odin Inspector/Config/Editor/InspectorConfig.asset
</span></span><span style="display:flex;"><span>UnityEngine.StackTraceUtility:ExtractStackTrace ()
</span></span><span style="display:flex;"><span>Sirenix.Utilities.GlobalConfigUtility`1&lt;Sirenix.OdinInspector.Editor.InspectorConfig&gt;:GetInstance (string,string) (at Y:/Repos/Sirenix-Development-Framework/Sirenix Solution/Sirenix.Utilities/Misc/GlobalConfig.cs:253)
</span></span><span style="display:flex;"><span>Sirenix.Utilities.GlobalConfig`1&lt;Sirenix.OdinInspector.Editor.InspectorConfig&gt;:get_Instance () (at Y:/Repos/Sirenix-Development-Framework/Sirenix Solution/Sirenix.Utilities/Misc/GlobalConfig.cs:80)
</span></span><span style="display:flex;"><span>Sirenix.OdinInspector.Editor.CustomEditorLoader:LoadCustomEditors () (at Y:/Repos/Sirenix-Development-Framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/CustomEditorLoader.cs:17)
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-txt" data-lang="txt"><span style="display:flex;"><span>Exception thrown while invoking [DidReloadScripts] method &#39;Sirenix.OdinInspector.Editor.CustomEditorLoader:LoadCustomEditors ()&#39; : UnityException: Creating asset at path Assets/Plugins/Sirenix/Odin Inspector/Config/Editor/InspectorConfig.asset failed.
</span></span><span style="display:flex;"><span>Sirenix.Utilities.GlobalConfigUtility`1[T].GetInstance (System.String defaultAssetFolderPath, System.String defaultFileNameWithoutExtension) (at Y:/Repos/Sirenix-Development-Framework/Sirenix Solution/Sirenix.Utilities/Misc/GlobalConfig.cs:253)
</span></span><span style="display:flex;"><span>Sirenix.Utilities.GlobalConfig`1[T].get_Instance () (at Y:/Repos/Sirenix-Development-Framework/Sirenix Solution/Sirenix.Utilities/Misc/GlobalConfig.cs:80)
</span></span><span style="display:flex;"><span>Sirenix.OdinInspector.Editor.CustomEditorLoader.LoadCustomEditors () (at Y:/Repos/Sirenix-Development-Framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/CustomEditorLoader.cs:17)
</span></span></code></pre></div><p>与 Assets/BoStaff_AnimSet_forUnity/Mesh/Dome.fbx 相关，暂时忽略</p>
<div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-txt" data-lang="txt"><span style="display:flex;"><span>ImportFBX Errors:
</span></span><span style="display:flex;"><span>Framerate was set to 0.00, it&#39;s been reset to 1.0.
</span></span></code></pre></div><p>与 Assets/Piloto Studio/Shaders/PBR_Piloto/PBR_UberShader.shader 相关，暂时忽略</p>
<div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-txt" data-lang="txt"><span style="display:flex;"><span>Shader error in &#39;Piloto Studio/PBR_UberShader&#39;: &#34;Undefined area shadow filter algorithm&#34; at /Workspaces/Unity/ARPG1/Library/PackageCache/com.unity.render-pipelines.high-definition@14.0.11/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl(53)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Compiling Subshader: 0, Pass: Forward, Fragment program with DECALS_OFF PROBE_VOLUMES_OFF SCREEN_SPACE_SHADOWS_OFF SHADOW_LOW USE_FPTL_LIGHTLIST
</span></span><span style="display:flex;"><span>Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
</span></span><span style="display:flex;"><span>Disabled keywords: DEBUG_DISPLAY DECALS_3RT DECALS_4RT DECAL_SURFACE_GRADIENT DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON INSTANCING_ON LIGHTMAP_ON PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 SCREEN_SPACE_SHADOWS_ON SHADER_API_GLES30 SHADOWS_SHADOWMASK SHADOW_HIGH SHADOW_MEDIUM SHADOW_VERY_HIGH UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING USE_CLUSTERED_LIGHTLIST _ALPHATEST_ON _DOUBLESIDED_ON _ENABLE_FOG_ON_TRANSPARENT _SURFACE_TYPE_TRANSPARENT _TRANSPARENT_WRITES_MOTION_VEC
</span></span></code></pre></div><ol start="6">
<li>进入 Assets/Scenes/Game.unity 场景。删除 Assets/Script 下的所有文件。课程后续会逐一开发</li>
<li>关闭编辑器再打开后，会在 HDRP Wizard 中的 Assets Migration 显示 Fix 按钮。但是点击后无反应，暂时忽略</li>
</ol>
<h2 id="认识扩展工具">认识扩展工具</h2>
<ol>
<li>Assets/Editor/PathHelper.cs 有三个方法</li>
</ol>
<ul>
<li>对 Hierarchy 中选中的对象进行如 Project 中右键 -&gt; Copy Path 功能</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75af00">[MenuItem(&#34;GameObject/CopyPath&#34;)]</span>
</span></span><span style="display:flex;"><span><span style="color:#00a8c8">public</span> <span style="color:#00a8c8">static</span> <span style="color:#00a8c8">void</span> <span style="color:#111">GetSelectGameObjectPath</span><span style="color:#111">()</span> <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">Selection</span><span style="color:#111">.</span><span style="color:#111">activeGameObject</span><span style="color:#111">!=</span><span style="color:#00a8c8">null</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">List</span><span style="color:#111">&lt;</span><span style="color:#00a8c8">string</span><span style="color:#111">&gt;</span> <span style="color:#111">str</span> <span style="color:#111">=</span> <span style="color:#00a8c8">new</span> <span style="color:#111">List</span><span style="color:#111">&lt;</span><span style="color:#00a8c8">string</span><span style="color:#111">&gt;();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">GetParentName</span><span style="color:#111">(</span><span style="color:#111">Selection</span><span style="color:#111">.</span><span style="color:#111">activeGameObject</span><span style="color:#111">.</span><span style="color:#111">transform</span><span style="color:#111">,</span><span style="color:#00a8c8">ref</span> <span style="color:#111">str</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">str</span><span style="color:#111">.</span><span style="color:#111">Reverse</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">string</span> <span style="color:#111">path</span> <span style="color:#111">=</span> <span style="color:#d88200">&#34;&#34;</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">for</span> <span style="color:#111">(</span><span style="color:#00a8c8">int</span> <span style="color:#111">i</span> <span style="color:#111">=</span> <span style="color:#ae81ff">1</span><span style="color:#111">;</span> <span style="color:#111">i</span> <span style="color:#111">&lt;</span> <span style="color:#111">str</span><span style="color:#111">.</span><span style="color:#111">Count</span><span style="color:#111">;</span> <span style="color:#111">i</span><span style="color:#111">++)</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#111">path</span> <span style="color:#111">+=</span> <span style="color:#111">str</span><span style="color:#111">[</span><span style="color:#111">i</span><span style="color:#111">]</span> <span style="color:#111">+</span> <span style="color:#d88200">&#34;/&#34;</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">path</span> <span style="color:#111">+=</span> <span style="color:#111">Selection</span><span style="color:#111">.</span><span style="color:#111">activeGameObject</span><span style="color:#111">.</span><span style="color:#111">name</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">TextEditor</span> <span style="color:#111">t</span> <span style="color:#111">=</span> <span style="color:#00a8c8">new</span> <span style="color:#111">TextEditor</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">t</span><span style="color:#111">.</span><span style="color:#111">text</span> <span style="color:#111">=</span> <span style="color:#d88200">$&#34;\&#34;</span><span style="color:#111">{</span><span style="color:#111">path</span><span style="color:#111">}</span><span style="color:#960050;background-color:#1e0010">\</span><span style="color:#d88200">&#34;&#34;</span><span style="color:#111">;</span><span style="color:#75715e">// path;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">t</span><span style="color:#111">.</span><span style="color:#111">OnFocus</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">t</span><span style="color:#111">.</span><span style="color:#111">Copy</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">Debug</span><span style="color:#111">.</span><span style="color:#111">Log</span><span style="color:#111">(</span><span style="color:#111">path</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span><span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#00a8c8">private</span> <span style="color:#00a8c8">static</span> <span style="color:#00a8c8">void</span> <span style="color:#111">GetParentName</span><span style="color:#111">(</span><span style="color:#111">Transform</span> <span style="color:#111">p</span><span style="color:#111">,</span><span style="color:#00a8c8">ref</span> <span style="color:#111">List</span><span style="color:#111">&lt;</span><span style="color:#00a8c8">string</span><span style="color:#111">&gt;</span> <span style="color:#111">str</span><span style="color:#111">)</span> <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">p</span><span style="color:#111">.</span><span style="color:#111">transform</span><span style="color:#111">.</span><span style="color:#111">parent</span> <span style="color:#111">!=</span> <span style="color:#00a8c8">null</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">str</span><span style="color:#111">.</span><span style="color:#111">Add</span><span style="color:#111">(</span><span style="color:#111">p</span><span style="color:#111">.</span><span style="color:#111">transform</span><span style="color:#111">.</span><span style="color:#111">parent</span><span style="color:#111">.</span><span style="color:#111">name</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">GetParentName</span><span style="color:#111">(</span><span style="color:#111">p</span><span style="color:#111">.</span><span style="color:#111">transform</span><span style="color:#111">.</span><span style="color:#111">parent</span><span style="color:#111">,</span><span style="color:#00a8c8">ref</span> <span style="color:#111">str</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span><span style="color:#111">}</span>
</span></span></code></pre></div><ul>
<li>在菜单栏的 Tools 下添加 <code>打开沙盒目录</code> 选项，可以打开当前项目在沙盒中的目录（本机为 C:\Users\Hcindy\AppData\LocalLow\DefaultCompany\ARPG1 ）</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75af00">[MenuItem(&#34;Tools/打开沙盒目录&#34;)]</span>
</span></span><span style="display:flex;"><span><span style="color:#00a8c8">public</span> <span style="color:#00a8c8">static</span> <span style="color:#00a8c8">void</span> <span style="color:#111">OpenPersistentDataPath</span><span style="color:#111">()</span> <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">Directory</span><span style="color:#111">.</span><span style="color:#111">Exists</span><span style="color:#111">(</span><span style="color:#111">Application</span><span style="color:#111">.</span><span style="color:#111">persistentDataPath</span><span style="color:#111">))</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">Application</span><span style="color:#111">.</span><span style="color:#111">OpenURL</span><span style="color:#111">(</span><span style="color:#111">Application</span><span style="color:#111">.</span><span style="color:#111">persistentDataPath</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span><span style="color:#111">}</span>
</span></span></code></pre></div><ul>
<li>校验 steam_api64.dll 的 MD5 值。代码中的 filePath 为硬编码，后续用到这个方法的时候，需要修改</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75af00">[MenuItem(&#34;Tools/获取SDK MD5&#34;)]</span>
</span></span><span style="display:flex;"><span><span style="color:#00a8c8">public</span> <span style="color:#00a8c8">static</span> <span style="color:#00a8c8">void</span> <span style="color:#111">GetFileHash</span><span style="color:#111">()</span>
</span></span><span style="display:flex;"><span><span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">try</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">var</span> <span style="color:#111">filePath</span> <span style="color:#111">=</span> <span style="color:#d88200">@&#34;F:/zyzpro 2/client/res_ZY/Assets/com.rlabrecque.steamworks.net/Plugins/steam_api64.dll&#34;</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">//Debug.LogError(GetFileHash());</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">FileStream</span> <span style="color:#111">filestream</span> <span style="color:#111">=</span> <span style="color:#111">File</span><span style="color:#111">.</span><span style="color:#111">OpenRead</span><span style="color:#111">(</span><span style="color:#111">filePath</span><span style="color:#111">);</span><span style="color:#75715e">//  new FileStream(filePath, FileMode.Open);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">int</span> <span style="color:#111">length</span> <span style="color:#111">=</span> <span style="color:#111">(</span><span style="color:#00a8c8">int</span><span style="color:#111">)</span><span style="color:#111">filestream</span><span style="color:#111">.</span><span style="color:#111">Length</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">byte</span><span style="color:#111">[]</span> <span style="color:#111">data</span> <span style="color:#111">=</span> <span style="color:#00a8c8">new</span> <span style="color:#00a8c8">byte</span><span style="color:#111">[</span><span style="color:#111">length</span><span style="color:#111">];</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">filestream</span><span style="color:#111">.</span><span style="color:#111">Read</span><span style="color:#111">(</span><span style="color:#111">data</span><span style="color:#111">,</span> <span style="color:#ae81ff">0</span><span style="color:#111">,</span> <span style="color:#111">length</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">filestream</span><span style="color:#111">.</span><span style="color:#111">Close</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">MD5</span> <span style="color:#111">md5</span> <span style="color:#111">=</span> <span style="color:#00a8c8">new</span> <span style="color:#111">MD5CryptoServiceProvider</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">byte</span><span style="color:#111">[]</span> <span style="color:#111">result</span> <span style="color:#111">=</span> <span style="color:#111">md5</span><span style="color:#111">.</span><span style="color:#111">ComputeHash</span><span style="color:#111">(</span><span style="color:#111">data</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">string</span> <span style="color:#111">fileMd5</span> <span style="color:#111">=</span> <span style="color:#d88200">&#34;&#34;</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">foreach</span> <span style="color:#111">(</span><span style="color:#00a8c8">byte</span> <span style="color:#111">item</span> <span style="color:#00a8c8">in</span> <span style="color:#111">result</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#111">fileMd5</span> <span style="color:#111">+=</span> <span style="color:#111">Convert</span><span style="color:#111">.</span><span style="color:#111">ToString</span><span style="color:#111">(</span><span style="color:#111">item</span><span style="color:#111">,</span> <span style="color:#ae81ff">16</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">Debug</span><span style="color:#111">.</span><span style="color:#111">LogError</span><span style="color:#111">(</span><span style="color:#111">fileMd5</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">//return fileMd5;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">catch</span> <span style="color:#111">(</span><span style="color:#111">FileNotFoundException</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">//return &#34;&#34;;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span><span style="color:#111">}</span>
</span></span></code></pre></div><ol start="2">
<li>Assets/Editor/ExcelTools 文件夹下有 <code>Excel2CS.cs</code> <code>ExcelDataReader.DataSet.dll</code> <code>ExcelDataReader.dll</code> <code>ExcelTools.cs</code> 四个文件。但教学视频中只将 <code>ExcelTools.cs</code> 里面的 Build2 方法暴露使用，用于读取指定目录（<code>excelInput = Application.dataPath + @&quot;\..\..\Tools\Excel\&quot;;</code>）下的 excel 文件，在指定目录（<code>outputCS = Application.dataPath + @&quot;\Script\Hotfix\ExcelConfig\&quot;;</code>）下生成 cs 文件，最后再触发编译，监听编译完成，编译完成后刷新 Assets 目录</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75af00">[MenuItem(&#34;Tools/Excel工具/生成游戏配置脚本&#34;)]</span>
</span></span><span style="display:flex;"><span><span style="color:#00a8c8">public</span> <span style="color:#00a8c8">static</span> <span style="color:#00a8c8">void</span> <span style="color:#111">Build2</span><span style="color:#111">()</span> <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">Application</span><span style="color:#111">.</span><span style="color:#111">isPlaying</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">UnityEngine</span><span style="color:#111">.</span><span style="color:#111">Debug</span><span style="color:#111">.</span><span style="color:#111">LogError</span><span style="color:#111">(</span><span style="color:#d88200">&#34;请先停止运行,再进行导表&#34;</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">return</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">KillWpsProcesses</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">EditorApplication</span><span style="color:#111">.</span><span style="color:#111">isCompiling</span> <span style="color:#111">==</span> <span style="color:#00a8c8">true</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">UnityEngine</span><span style="color:#111">.</span><span style="color:#111">Debug</span><span style="color:#111">.</span><span style="color:#111">LogError</span><span style="color:#111">(</span><span style="color:#d88200">$&#34;请等待编译完成后再生成.&#34;</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">return</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">Init</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#00a8c8">string</span><span style="color:#111">.</span><span style="color:#111">IsNullOrEmpty</span><span style="color:#111">(</span><span style="color:#111">excelInput</span><span style="color:#111">))</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">UnityEngine</span><span style="color:#111">.</span><span style="color:#111">Debug</span><span style="color:#111">.</span><span style="color:#111">LogError</span><span style="color:#111">(</span><span style="color:#d88200">&#34;请配置Excel输入目录&#34;</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">return</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#00a8c8">string</span><span style="color:#111">.</span><span style="color:#111">IsNullOrEmpty</span><span style="color:#111">(</span><span style="color:#111">outputCS</span><span style="color:#111">))</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">UnityEngine</span><span style="color:#111">.</span><span style="color:#111">Debug</span><span style="color:#111">.</span><span style="color:#111">LogError</span><span style="color:#111">(</span><span style="color:#d88200">&#34;请配置CS输出目录&#34;</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">return</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">var</span> <span style="color:#111">r</span><span style="color:#111">=</span> <span style="color:#111">Excel2CS</span><span style="color:#111">.</span><span style="color:#111">Start</span><span style="color:#111">(</span><span style="color:#111">excelInput</span><span style="color:#111">,</span> <span style="color:#111">outputCS</span><span style="color:#111">,</span><span style="color:#00a8c8">false</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">r</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">CompilationPipeline</span><span style="color:#111">.</span><span style="color:#111">RequestScriptCompilation</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">CompilationPipeline</span><span style="color:#111">.</span><span style="color:#111">compilationFinished</span> <span style="color:#111">+=</span> <span style="color:#111">(</span><span style="color:#111">obj</span><span style="color:#111">)</span> <span style="color:#111">=&gt;</span> <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#111">UnityEngine</span><span style="color:#111">.</span><span style="color:#111">Debug</span><span style="color:#111">.</span><span style="color:#111">Log</span><span style="color:#111">(</span><span style="color:#d88200">&#34;批处理执行完毕!&#34;</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>            <span style="color:#111">AssetDatabase</span><span style="color:#111">.</span><span style="color:#111">Refresh</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">};</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span><span style="color:#111">}</span>
</span></span></code></pre></div><ol start="3">
<li>Assets/Editor/UITools.cs 有一个方法，再无研究</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75af00">[MenuItem(&#34;Assets/创建图片&#34;, priority = 49)]</span>
</span></span><span style="display:flex;"><span><span style="color:#00a8c8">public</span> <span style="color:#00a8c8">static</span> <span style="color:#00a8c8">void</span> <span style="color:#111">CreateImage</span><span style="color:#111">()</span>
</span></span><span style="display:flex;"><span><span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">UnityEngine</span><span style="color:#111">.</span><span style="color:#111">Object</span><span style="color:#111">[]</span> <span style="color:#111">objs</span> <span style="color:#111">=</span> <span style="color:#111">Selection</span><span style="color:#111">.</span><span style="color:#111">objects</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">//等下物体创建完毕后，需要设置到这个根节点下</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">var</span> <span style="color:#111">canvas</span><span style="color:#111">=</span><span style="color:#111">GameObject</span><span style="color:#111">.</span><span style="color:#111">FindObjectOfType</span><span style="color:#111">&lt;</span><span style="color:#111">Canvas</span><span style="color:#111">&gt;();</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">Transform</span> <span style="color:#111">tra</span> <span style="color:#111">=</span> <span style="color:#111">canvas</span><span style="color:#111">.</span><span style="color:#111">transform</span><span style="color:#111">;</span> <span style="color:#75715e">/* GameObject.Find(&#34;UIRoot&#34;).transform;*/</span>
</span></span><span style="display:flex;"><span>    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">objs</span><span style="color:#111">.</span><span style="color:#111">Length</span> <span style="color:#111">&gt;</span> <span style="color:#ae81ff">0</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#00a8c8">for</span> <span style="color:#111">(</span><span style="color:#00a8c8">int</span> <span style="color:#111">i</span> <span style="color:#111">=</span> <span style="color:#ae81ff">0</span><span style="color:#111">;</span> <span style="color:#111">i</span> <span style="color:#111">&lt;</span> <span style="color:#111">objs</span><span style="color:#111">.</span><span style="color:#111">Length</span><span style="color:#111">;</span> <span style="color:#111">i</span><span style="color:#111">++)</span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">objs</span><span style="color:#111">[</span><span style="color:#111">i</span><span style="color:#111">]</span> <span style="color:#00a8c8">is</span> <span style="color:#111">Texture2D</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>            <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#00a8c8">string</span> <span style="color:#111">path</span> <span style="color:#111">=</span> <span style="color:#111">AssetDatabase</span><span style="color:#111">.</span><span style="color:#111">GetAssetPath</span><span style="color:#111">(</span><span style="color:#111">objs</span><span style="color:#111">[</span><span style="color:#111">i</span><span style="color:#111">]);</span><span style="color:#75715e">//获取路径</span>
</span></span><span style="display:flex;"><span>                <span style="color:#111">TextureImporter</span> <span style="color:#111">ti</span> <span style="color:#111">=</span> <span style="color:#111">TextureImporter</span><span style="color:#111">.</span><span style="color:#111">GetAtPath</span><span style="color:#111">(</span><span style="color:#111">path</span><span style="color:#111">)</span> <span style="color:#00a8c8">as</span> <span style="color:#111">TextureImporter</span><span style="color:#111">;</span> <span style="color:#75715e">//获取TextureImporter</span>
</span></span><span style="display:flex;"><span>                <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">ti</span><span style="color:#111">.</span><span style="color:#111">textureType</span> <span style="color:#111">==</span> <span style="color:#111">TextureImporterType</span><span style="color:#111">.</span><span style="color:#111">Sprite</span><span style="color:#111">)</span>
</span></span><span style="display:flex;"><span>                <span style="color:#111">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#75715e">//,typeof(Button)</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#111">GameObject</span> <span style="color:#111">go</span> <span style="color:#111">=</span> <span style="color:#00a8c8">new</span> <span style="color:#111">GameObject</span><span style="color:#111">(</span><span style="color:#111">objs</span><span style="color:#111">[</span><span style="color:#111">i</span><span style="color:#111">].</span><span style="color:#111">name</span><span style="color:#111">,</span> <span style="color:#00a8c8">new</span> <span style="color:#111">Type</span><span style="color:#111">[]</span> <span style="color:#111">{</span> <span style="color:#00a8c8">typeof</span><span style="color:#111">(</span><span style="color:#111">Image</span><span style="color:#111">)</span> <span style="color:#111">});</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#111">go</span><span style="color:#111">.</span><span style="color:#111">transform</span><span style="color:#111">.</span><span style="color:#111">SetParent</span><span style="color:#111">(</span><span style="color:#111">tra</span><span style="color:#111">,</span> <span style="color:#00a8c8">false</span><span style="color:#111">);</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#00a8c8">var</span> <span style="color:#111">image</span> <span style="color:#111">=</span> <span style="color:#111">go</span><span style="color:#111">.</span><span style="color:#111">GetComponent</span><span style="color:#111">&lt;</span><span style="color:#111">Image</span><span style="color:#111">&gt;();</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#111">image</span><span style="color:#111">.</span><span style="color:#111">type</span> <span style="color:#111">=</span> <span style="color:#111">Image</span><span style="color:#111">.</span><span style="color:#111">Type</span><span style="color:#111">.</span><span style="color:#111">Simple</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#111">UnityEngine</span><span style="color:#111">.</span><span style="color:#111">Object</span> <span style="color:#111">newImg</span> <span style="color:#111">=</span> <span style="color:#111">UnityEditor</span><span style="color:#111">.</span><span style="color:#111">AssetDatabase</span><span style="color:#111">.</span><span style="color:#111">LoadAssetAtPath</span><span style="color:#111">(</span><span style="color:#111">path</span><span style="color:#111">,</span> <span style="color:#00a8c8">typeof</span><span style="color:#111">(</span><span style="color:#111">Sprite</span><span style="color:#111">));</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#111">Undo</span><span style="color:#111">.</span><span style="color:#111">RecordObject</span><span style="color:#111">(</span><span style="color:#111">image</span><span style="color:#111">,</span> <span style="color:#d88200">&#34;Change Image&#34;</span><span style="color:#111">);</span><span style="color:#75715e">//有了这句才可以用ctrl+z撤消此赋值操作</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#111">image</span><span style="color:#111">.</span><span style="color:#111">sprite</span> <span style="color:#111">=</span> <span style="color:#111">newImg</span> <span style="color:#00a8c8">as</span> <span style="color:#111">Sprite</span><span style="color:#111">;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#111">image</span><span style="color:#111">.</span><span style="color:#111">SetNativeSize</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span>                <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#111">AssetDatabase</span><span style="color:#111">.</span><span style="color:#111">Refresh</span><span style="color:#111">();</span>
</span></span><span style="display:flex;"><span><span style="color:#111">}</span>
</span></span></code></pre></div><h2 id="读-excel-表生成-cs-文件">读 excel 表，生成 cs 文件</h2>
<ol>
<li>将 Tools 文件夹（课程资料包中）放置到与 ARPG1 文件夹同级目录下（因为导表工具中写的路径是 <code>\..\..\Tools\Excel\</code>）</li>
<li>点击 Tools &gt; Excel工具 &gt; 生成游戏配置脚本</li>
<li>会解析四个xlsx文件，生成五个cs文件</li>
</ol>
<ul>
<li><code>单位基础表_Unit.xlsx</code> 定义所有角色（玩家和NPC）的属性</li>
<li><code>技能表_Skill.xlsx</code> 定义所有技能的属性，会被关联到 <code>单位基础表_Unit.xlsx</code> 中</li>
<li><code>角色属性表_UnitAtt.xlsx</code> 定义有共性的属性模板，会被关联到 <code>单位基础表_Unit.xlsx</code> 中</li>
<li><code>角色状态_PlayerState.xlsx</code> 控制角色所有主动、被动和与其它对象交互的定义</li>
<li><code>Assets/Script/Hotfix/ExcelConfig/GlobalConfig.cs</code></li>
<li><code>Assets/Script/Hotfix/ExcelConfig/PlayerStateData.cs</code></li>
<li><code>Assets/Script/Hotfix/ExcelConfig/SkillData.cs</code></li>
<li><code>Assets/Script/Hotfix/ExcelConfig/UnitAttData.cs</code></li>
<li><code>Assets/Script/Hotfix/ExcelConfig/UnitData.cs</code></li>
</ul>
<p>用 excel 定义游戏元素的属性：</p>
<ul>
<li>比起 txt markdown 数据库 扩展Unity 更容易对数据进行编辑；</li>
<li>不论用哪种方式定义，包括额外开发配套的配置软件，都需要定义设计“套路”并用软件解析；</li>
<li>不同的游戏定义的元素必然不同，解析软件需要定制修改；</li>
<li>以面向对象的思想开发游戏，定义的数据需要转换成类。类可以是DO（面向数据库）也可以是BO（面向业务），但做游戏应该不会用到mysql之类的数据库，所以转换成BO，或者BO的工厂类，在程序运行时直接访问或创建对象；</li>
<li>修改数据后，就需要重新生成CS文件</li>
</ul>


    


                    
                    <div class="row"></div> 

                </div>

            </div> 

        </div> 
<script src="/lib/jquery.min.js"></script> 
<script src="/lib/popper.min.js"></script> 

<script src="/js/bootstrap.min.js"></script> 


<script type="text/javascript" src="/plugins/lunr.min.js"></script>
<script type="text/javascript" src="/plugins/auto-complete.js"></script>
<link href="/plugins/auto-complete.css" rel="stylesheet">
<script type="text/javascript">
  
      var baseurl = "\/";
  
</script>
<script type="text/javascript" src="/plugins/search.js"></script>

<script type="text/javascript" src="/plugins/favorites.js"></script>


<script type="text/javascript" src="/plugins/clipboard.js"></script>
<script>
  new ClipboardJS('.btn');
</script>
</body>
</html>
